export default {
  namespace: 'login',
  state: {
    //用户信息
    userInfo: {},
    //权限id
    roleId: '',
  },
  reducers: {
    //保存用户信息
    save(state, { payload }) {
      console.log('======= state =======\n', state);
      console.log('======= payload =======\n', payload);
      return {
        ...state,
        ...payload,
      };
    },
  },
  effects: {
    *login({ payload }, { call, put }) {
      const { data } = yield call(login, payload);
      console.log('======= data =======\n', data);
      if (data.code === 200) {
        yield put({
          type: 'save',
        });
      }
    },
  },
};
